import { getCateListApi } from "@/api";

export default {
  namespaced: true, // 开启命名空间，让模块独立
  state: () => ({
    cateList: [],
    allTagList: []
  }),
  getters: {
    newCateName(state) {
      return state.cateList.map(item => item.catename)
    },
    newCateId(state) {
      return state.cateList.map(item => item.id)
    },
  },
  mutations: {
    getCateList(state, { allCate, allTag }) {
      state.cateList = allCate
      state.allTagList = allTag
    }
  },
  actions: {
    async getCateList({ commit }) {
      const { data } = await getCateListApi()
      // console.log(data);
      commit('getCateList', data)
    },
  },
}